< previous page page_506 next page >

Page 506
9f31265bb40b592b1929e18a47ab28e5.gif
      End If
   Next

   If Not boolFound Then
      ctlAny.ListIndex = -1
   End If
End Sub
The two arguments you pass to this procedure are the combo box or list box and the long integer you want to find in the ItemData() property. If you find the data when youre looping through the loop, you need to set the ListIndex property to the location in the combo or list box.
The Field2CheckBox() Function
As with the Field2Str() function, you need to check a field value with the Field2CheckBox() function to see whether its Null; if it is, you need to change the value to something appropriate for check box Value property:
9f31265bb40b592b1929e18a47ab28e5.gif
Public Function Field2CheckBox(vntField As Variant) As Integer
   If IsNull(vntField) Then
      Field2CheckBox = vbUnchecked
   Else
      Field2CheckBox = IIf(vntField, vbChecked, vbUnchecked)
   End If
End Function
This function returns either the vbUnchecked constant or the vbChecked constant. Notice the use of the IIF() function. This function returns the second parameter if the first parameter evaluates to a True condition or the third parameter if the first parameter evaluates to a False condition. A nice advantage to this routine is that you can use any numeric data type to store the Value property of a check boxit doesnt need to be a Yes/No type of field (which not all databases support).
Adding Data
To add a new employee to the database, the user needs to click the New command button. In this button youll write code to clear all the controls so that the user has blank space in which to add a new employee:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdNew_Click()
   mboolAdding = True

 
< previous page page_506 next page >

If you like this book, buy it!